package com.myapp.web.struts2.multipart;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;

public class AjaxProgressRequestContextListener implements ServletRequestListener {
	  
	  static final Logger LOG = LoggerFactory.getLogger(AjaxProgressRequestContextListener.class);
	 
	  public void requestDestroyed(ServletRequestEvent requestEvent){
		    Object attributes = (ServletRequestAttributes)requestEvent.getServletRequest().getAttribute(ProgressMultiPartRequest.PROGRESS_KEY);
			if(attributes != null){
				requestEvent.getServletRequest().removeAttribute(ProgressMultiPartRequest.PROGRESS_KEY);
				LOG.debug("destory " + ProgressMultiPartRequest.PROGRESS_KEY + "in request");
			}
	  }	  
	  
	  public void requestInitialized(ServletRequestEvent event){
		  
	  }
}
